from TurtleWorld import *
from math import *
 
world=TurtleWorld()
joe=Turtle()
joe.delay = 0.055
joe.color = "purple"
#----------------------------TRIANGLES----------------------------#

def equilateral_tri(t, size=100, rotate=0):
	for i in range(3):
		t.lt(rotate)
		t.fd(size)
		t.lt(120)
	t.lt(rotate)
#--------------------------QUADRILATERALS-------------------------#

def para(t, width=100, height=100, angle=120, rotate=0):
	for i in range(1):
		t.lt(rotate)
		t.fd(width)
		t.rt(angle)
		t.fd(height)
		t.rt(180-angle)
		t.fd(width)
		t.rt(angle)
		t.fd(height)
		t.lt(rotate)

def rhom(t, size=100, angle=120, rotate=0,):
	for i in range(1):
		t.lt(rotate)
		t.fd(size)
		t.rt(angle)
		t.fd(size)
		t.rt(180-angle)
		t.fd(size)
		t.rt(angle)
		t.fd(size)
		t.lt(rotate)

def rect(t, width=100, height=100, rotate=0):
	for i in range(2):
		t.lt()
		t.fd(width)
		t.lt()
		t.fd(height)
	t.lt(rotate)

def square(t, size=100, rotate=0):
	for i in range(4):
		t.fd(size)
		t.lt(rotate)
	
 
#------------------------------MOVEMENT---------------------------#

def line(t, x=100, y=100):
	dist = sqrt(x**2 + y**2)
	angle = degrees(atan(y/float(x)))
	t.rt(angle)
	t.fd(dist)

	print "Line to a point X:", x, "over and Y:", y, "up"
  
def move(t, x, y):
	t.pu()
	dist = sqrt(x**2 + y**2)
	angle = degrees(atan(y/float(x)))
	t.rt(angle)
	t.fd(dist)
	t.pd()
	print "Move without marking to a point X:", x, "over and Y:", y, "up"
	
	
def circle(t, size, angle, rotate):
	for i in range(360):
		t.rt(rotate)
		t.rt(20-angle)
		t.fd(size)
#------------------------------OTHER SHAPES------------------------#
"""
Build any other shape functions you want.
Some Ideas:
	Right Triangles (sss, sas, etc)
	Arbitrary Triangles
	Circle
	Arcs
	Go Wild!
	
Bonus for working or challenging functions...no penalty for trying something
"""
joe.pu()
joe.fd(400)
joe.rt()
joe.fd(100)
joe.lt()
joe.pd()
equilateral_tri(joe, 150, 120)


joe.pu()
joe.lt()
joe.fd(200)
joe.pd()
rect(joe, 150, 50, 90)
joe.pu()
joe.lt()
joe.fd(375)
joe.rt()
joe.fd(120)
joe.lt()
joe.pd()
square(joe, 150, 90)
joe.pu()
joe.rt()
joe.fd(300)
joe.pd()
para(joe, 150, 63, 45)
joe.pu()
joe.lt()
joe.fd(150)
joe.pd()
rhom(joe, 150, 45, 100)
joe.pu()
joe.fd(100)
joe.pd()
joe.rt()
line(joe, 150, 100)
joe.pu()
joe.rt()
joe.fd(50)
joe.lt()
joe.fd(100)
joe.pd()
move(joe, 150, 100)
circle(joe, 4, 1, 1)

#------------------------------TEST-------------------------------#



wait_for_user()